package com.example.publishsubscribepattern.observer;

import com.example.publishsubscribepattern.subject.ConcreteSubject1;
import com.example.publishsubscribepattern.subject.Subject;

/**
 * @author ash
 * @description
 * @create 2023/2/14  23:03:08
 * @className ConcreteObserver1
 * @verson 1.0.0
 */
public class ConcreteObserver1 extends Observer {

    private String name;

    private String observerStatus;

    private ConcreteSubject1 concreteSubject1;


    public ConcreteObserver1(String name, ConcreteSubject1 concreteSubject1) {
        this.name = name;
        this.concreteSubject1 = concreteSubject1;
    }

    @Override
   public void update() {
        observerStatus = concreteSubject1.getStatus();
        System.out.println("ConcreteObserver1观察者收到通知!!名称:" + name + ",状态:" + observerStatus);
    }


    public ConcreteSubject1 getConcreteSubject1() {
        return concreteSubject1;
    }

    public void setConcreteSubject1(ConcreteSubject1 concreteSubject1) {
        this.concreteSubject1 = concreteSubject1;
    }
}
